package com.itheima.mapDemo2;

import java.util.HashMap;
import java.util.Set;

public class HashMapDemo1 {
    public static void main(String[] args) {
        HashMap<Student, String> hm = new HashMap<>();

        hm.put(new Student("zhangsan", 23), "Beijing");
        hm.put(new Student("lisi", 24), "Shanghai");
        hm.put(new Student("zhangsan", 25), "Guangzhou");
        hm.put(new Student("zhangsan", 25), "Shenzhen");

        // 遍历一
        Set<Student> keys = hm.keySet();
        for (Student key : keys) {
            System.out.println(key + "=" + hm.get(key));
        }
        System.out.println("----------------");
        // 遍历二
        hm.forEach((student, s) -> System.out.println(student + "=" + s));
    }
}
